package org.springblade.pm.wrappper;

import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.pm.entity.ClientSatisfaction;
import org.springblade.pm.vo.ClientSatisfactionVo;
import org.springblade.pm.vo.ContractVo;
import org.springblade.system.user.feign.IUserClient;

import java.util.ArrayList;
import java.util.List;

public class ClientSatisfactionWrapper extends BaseEntityWrapper<ClientSatisfaction,ClientSatisfactionVo> {

	static IUserClient userClient;
	static {
		userClient = SpringUtil.getBean(IUserClient.class);
	}

	public static ClientSatisfactionWrapper build() {
		return new ClientSatisfactionWrapper();
	}

	@Override
	public ClientSatisfactionVo entityVO(ClientSatisfaction entity) {
		ClientSatisfactionVo clientSatisfactionVo = BeanUtil.copy(entity, ClientSatisfactionVo.class);
		String realName = userClient.userInfo(Long.valueOf(entity.getCreateUser().toString())).getData().getUser().getRealName();

		if (realName!=null&&!"".equals(realName)) {
			clientSatisfactionVo.setCreateUserName(realName);
		}
		return clientSatisfactionVo;
	}

	public List<ClientSatisfactionVo> entityVoList(List<ClientSatisfaction> list) {
		List<ClientSatisfactionVo> clientSatisfactionVoList = new ArrayList<>();
		for (ClientSatisfaction clientSatisfaction : list) {
			clientSatisfactionVoList.add(entityVO(clientSatisfaction));
		}
		return clientSatisfactionVoList;
	}

}
